FROM node:16.13.0 as build-stage
ARG STAGE
RUN mkdir -p /data/www
WORKDIR /data/www
ADD package.json /data/www/
RUN npm install
ADD ./ /data/www
RUN npm run build:${STAGE}

FROM nginx
ARG STAGE
COPY --from=build-stage /data/www/dist /usr/share/nginx/html
ADD ./deploy/${STAGE}/nginx.conf /etc/nginx/nginx.conf
ADD ./deploy/${STAGE}/nginx.vue.default.conf /etc/nginx/conf.d/default.conf

RUN mkdir -p /etc/nginx/cert/
ADD ./deploy/cert/scrm.keyid.cn.key /etc/nginx/cert/
ADD ./deploy/cert/scrm.keyid.cn.pem /etc/nginx/cert/



EXPOSE 80
EXPOSE 443
CMD ["nginx", "-g", "daemon off;"]
